'use strict';

angular.module('app').run(['$rootScope', '$state', '$stateParams',
    function($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
    }
]).config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {
        // 默认页面 登录页面
        $urlRouterProvider.otherwise('/douxiaoli/commoditymanagement/addgoods');

        $stateProvider.state('douxiaoli', {
            abstract: true,
            url: '/douxiaoli',
            templateUrl: 'tpl/app.html'
        })

        // 商品管理
        .state('douxiaoli.commoditymanagement', {
            url: '/commoditymanagement',
            template: '<div ui-view class="fade-in-up"></div>'
        })

        // 商品管理_查看商品
        .state('douxiaoli.commoditymanagement.viewgoods', {
            url: '/viewgoods',
            templateUrl: 'tpl/commoditymanagement_viewgoods.html',
            resolve: {
                deps: ['uiLoad',
                    function(uiLoad) {
                        return uiLoad.load('js/controllers/commoditymanagement_viewgoods.js');
                    }
                ]
            }
        })

        // 商品管理_添加商品
        .state('douxiaoli.commoditymanagement.addgoods', {
            url: '/addgoods',
            templateUrl: 'tpl/commoditymanagement_addgoods.html',
            resolve: {
                deps: ['uiLoad',
                    function(uiLoad) {
                        return uiLoad.load('js/controllers/commoditymanagement_addgoods.js');
                    }
                ]
            }
        })

        // 栏目管理
        .state('douxiaoli.columnmanagement', {
            url: '/columnmanagement',
            template: '<div ui-view class="fade-in-up"></div>'
        })

        // 栏目管理_查看栏目
        .state('douxiaoli.columnmanagement.viewcolumn', {
            url: '/viewgoods',
            templateUrl: 'tpl/columnmanagement_viewcolumn.html',
            resolve: {
                deps: ['uiLoad',
                    function(uiLoad) {
                        return uiLoad.load('js/controllers/columnmanagement_viewcolumn.js');
                    }
                ]
            }
        })

        // 栏目管理_添加栏目
        .state('douxiaoli.columnmanagement.addcolumn', {
            url: '/addcolumn',
            templateUrl: 'tpl/columnmanagement_addcolumn.html',
            resolve: {
                deps: ['uiLoad',
                    function(uiLoad) {
                        return uiLoad.load('js/controllers/columnmanagement_addcolumn.js');
                    }
                ]
            }
        })

        // 分类管理
        .state('douxiaoli.classifiedmanagement', {
            url: '/classifiedmanagement',
            templateUrl: 'tpl/classifiedmanagement.html',
            resolve: {
                deps: ['uiLoad',
                    function(uiLoad) {
                        return uiLoad.load('js/controllers/classifiedmanagement.js');
                    }
                ]
            }
        })

        .state('access', {
            url: '/access',
            template: '<div ui-view class="fade-in-right-big smooth"></div>'
        })

        // 登录
        .state('access.signin', {
            url: '/signin',
            templateUrl: 'tpl/signin.html',
            resolve: {
                deps: ['uiLoad',
                    function(uiLoad) {
                        return uiLoad.load(['js/controllers/signin.js']);
                    }
                ]
            }
        })
    }
]);